﻿using System;
using System.Management;
using System.Management.Automation;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Publishing;

namespace SPPoSh.Cmdlets.Artefacts.PublishingCache
{
    [Cmdlet(VerbsCommon.Clear, "PublishingCache")]
    public class ClearPublishingCacheCmdlet : Cmdlet
    {
        [Parameter(Position = 0, Mandatory = true, HelpMessage = "URL of the web application.")]
        public string WebApplication;

        protected override void ProcessRecord()
        {
            SPWebApplication webApp = SPWebApplication.Lookup(new Uri(WebApplication));
            Microsoft.SharePoint.Publishing.PublishingCache.FlushBlobCache(webApp);
        }
    }
}
